#include"bits/stdc++.h"
using namespace std;
int n;
struct people{
	string xp;
	int index;
};
people prisident[21];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>prisident[i].xp;
		prisident[i].index=i;
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			int len1=strlen(prisident[j].xp.c_str());
			int len2=strlen(prisident[j+1].xp.c_str());
			if(len1<len2)
			{
				swap(prisident[j],prisident[j+1]);
			}
			else if(len1==len2&&prisident[j].xp<prisident[j+1].xp)
			{
				swap(prisident[j],prisident[j+1]);
			}
		}
	}
	cout<<prisident[1].index<<endl<<prisident[1].xp;
}
